CookieStore

A service that allows working with the session and persistent cookies.

Cookies can be stored in the process memory (session cookies) or on the file system (persistent cookies). The service provides access to both the session and persistent cookies.

The persistent cookies are stored in the user data directory. You can configure the user data directory path via the userDataDir method. For example:

Engine engine = Engine.newInstance(EngineOptions.newBuilder(renderingMode)
        .userDataDir(Paths.get("/Users/MyApp/Data"))
.build());

All the changes to the cookie store are made in memory, so when you restart the application you will not see the changes you made with the persistent cookies if you do not invoke the persist method before application exit.

Functions

Link copied to clipboard
abstract fun cookies(): List<Cookie>
Returns an immutable list of all the cookies available in the cookie store.
abstract fun cookies(url: String): List<Cookie>
Returns an immutable list of cookies for the given url.
Link copied to clipboard
abstract fun delete(cookie: Cookie)
Deletes the given cookie from the cookie store.
Link copied to clipboard
abstract fun deleteAll(): Int
Deletes all the cookies from the cookie store and returns the number of deleted cookies.
Link copied to clipboard
abstract fun persist()
Persists all the changes performed to the cookie store.
Link copied to clipboard
abstract fun profile(): Profile
Returns the profile of this service.
Link copied to clipboard
abstract fun set(cookie: Cookie)
Sets the cookie.